package com.wootion.cims.general.utils;

/**
 * 基于ThreadLocal封装工具类，存储当前用户登录的信息
 * ，可以配合mybatis-plus的注解，一起使用
 * @TableField(fill = FieldFill.INSERT_UPDATE)//插入和更新时自动填充字段
 */
@SuppressWarnings("all")
public class BaseContext {
    private static final ThreadLocal<String> threadLocalCommunityId = new ThreadLocal<>();
    private static final ThreadLocal<String> threadLocalPlotId = new ThreadLocal<>();
    private static final ThreadLocal<String> threadLocalAbode = new ThreadLocal<>();
    private static final ThreadLocal<Integer> threadLocal = new ThreadLocal<>();
    private static final ThreadLocal<Long> threadLocalLang = new ThreadLocal<>();
    public static void setCurrentId(int id){
       threadLocal.set(id);
    }
    public static int getCurrentId(){
        return threadLocal.get();
    }
    public static void setCurrentIdLang(Long id){
        threadLocalLang.set(id);
    }
    public static Long getCurrentIdLang(){
        return threadLocalLang.get();
    }


    public static void setLocalCommunityId(String communityId){
        threadLocalCommunityId.set(communityId);
    }
    public static String getLocalCommunityId(){
        return threadLocalCommunityId.get();
    }
    public static void removeCommunityId(){
        threadLocalCommunityId.remove();
    }

    public static void setLocalPlotId(String plotId){
        threadLocalPlotId.set(plotId);
    }
    public static String getLocalPlotId(){
        return threadLocalPlotId.get();
    }
    public static void removePlotId(){
        threadLocalPlotId.remove();
    }
    public static void setLocalAbode(String abode){
        threadLocalAbode.set(abode);
    }
    public static String getLocalAbode(){
        return threadLocalAbode.get();
    }
    public static void removeAbode(){
        threadLocalAbode.remove();
    }
}